var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  default: () => stdin_default
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_utils = require("../utils");
var import_picker = __toESM(require("../picker/picker.js"));
var import_vue2 = require("vue");
const __vue_sfc__ = (0, import_vue.defineComponent)({
  name: (0, import_utils.createNamespace)("TimePicker")[0],
  options: { virtualHost: true },
  emits: ["update:show", "update:modelValue", "confirm", "cancel"],
  components: { FanPicker: import_picker.default },
  props: {
    modelValue: {
      type: Array,
      default: () => []
    },
    show: {
      type: Boolean,
      default: false
    },
    title: String,
    filter: {
      type: [Function, null],
      default: null
    },
    cancelText: {
      type: String,
      default: "\u53D6\u6D88"
    },
    confirmText: {
      type: String,
      default: "\u786E\u8BA4"
    },
    second: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const formatTime = (val, type) => {
      let arr = Array.from({ length: val }, (_, index) => index < 10 ? `0${index}` : index);
      if (props.filter)
        arr = props.filter(type, arr);
      arr = arr.map((item, index) => ({ text: item, id: index < 10 ? `0${index}` : String(index), index }));
      return arr;
    };
    const state = (0, import_vue.reactive)({
      innerShow: props.show,
      value: props.modelValue,
      hours: formatTime(24, "hours"),
      minute: formatTime(60, "minute"),
      second: formatTime(60, "second")
    });
    const list = (0, import_vue.computed)(() => {
      let l = [state.hours, state.minute];
      if (props.second)
        l.push(state.second);
      return l;
    });
    const onConfirm = (val) => emit("confirm", val);
    const onCancel = (val) => emit("cancel");
    (0, import_vue.watch)(props.modelValue, (val) => {
      state.value = [...val];
    }, { deep: true });
    (0, import_vue.watch)(() => state.value, (val) => {
      emit("update:modelValue", val);
    }, { deep: true });
    (0, import_vue.watch)(() => props.show, (val) => state.innerShow = val);
    (0, import_vue.watch)(() => state.innerShow, (val) => emit("update:show", val));
    return { state, list, onConfirm, onCancel };
  }
});
function __vue_render__(_ctx, _cache) {
  const _component_FanPicker = (0, import_vue2.resolveComponent)("FanPicker");
  return (0, import_vue2.openBlock)(), (0, import_vue2.createBlock)(_component_FanPicker, {
    modelValue: _ctx.state.value,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.state.value = $event),
    show: _ctx.state.innerShow,
    "onUpdate:show": _cache[1] || (_cache[1] = ($event) => _ctx.state.innerShow = $event),
    data: _ctx.list,
    "value-key": "id",
    title: _ctx.title,
    "cancel-text": _ctx.cancelText,
    "confirm-text": _ctx.confirmText,
    onConfirm: _ctx.onConfirm,
    onCancel: _ctx.onCancel
  }, (0, import_vue2.createSlots)({
    _: 2
    /* DYNAMIC */
  }, [
    _ctx.$slots.default ? {
      name: "header",
      fn: (0, import_vue2.withCtx)(() => [
        (0, import_vue2.renderSlot)(_ctx.$slots, "default")
      ]),
      key: "0"
    } : void 0
  ]), 1032, ["modelValue", "show", "data", "title", "cancel-text", "confirm-text", "onConfirm", "onCancel"]);
}
__vue_sfc__.render = __vue_render__;
var stdin_default = __vue_sfc__;
